// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env: 'car-test-1jjya',
    traceUser: true
})
const db = cloud.database()
const stopCarsdb = db.collection('cars')

// 云函数入口函数
exports.main = async(event, context) => {
    const wxContext = cloud.getWXContext()
    return carstop(event)
}

async function carstop(event) {
    console.log(event)

    var result = await stopCarsdb.where({ _id: event.carid }).update({
        data: event,
    });
    console.log(result)
    if (result.stats.updated) { // 判断是否更新成功
        return 'success'
    } else {
        return 'error'
    }

}